package org.openea.eap.module.obpm.controller.custchart;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.openbpm.base.api.aop.annotion.CatchErr;
import org.openbpm.base.api.response.impl.ResultMsg;
import org.openbpm.base.core.util.StringUtil;
import org.openbpm.base.rest.BaseController;
import org.openea.eap.module.obpm.model.custchart.FormCustChart2;
import org.openea.eap.module.obpm.service.custchart.FormCustChart2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/form/formCustChart2/"})
public class FormCustChart2Controller extends BaseController<FormCustChart2>  {

    @Autowired
    private FormCustChart2Service formCustChartService;

    //get,getByCode,save,remove,listJson

    @RequestMapping({"/getByCode"})
    @CatchErr
    public ResultMsg<FormCustChart2> getByCode(@RequestParam String code) throws Exception {
        if (StringUtil.isEmpty(code)) {
            return ResultMsg.ERROR("ID不能为空");
        }
        FormCustChart2 formCustChart = formCustChartService.getOne(new QueryWrapper<FormCustChart2>().lambda().eq(FormCustChart2::getCode, code));
        return formCustChart == null ? ResultMsg.ERROR("自定义列表不存在,code:" + code) : ResultMsg.SUCCESS(formCustChart);
    }

    @Override
    protected String getModelDesc() {
        return "Cust Chart";
    }

}
